﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Exhibition.Common.Helper;
using Exhibition.Dao.ViewModel;
using Exhibition.Service;

namespace Exhibition.Manage
{
    public partial class FrindLinkDetail : BaseAdminPage
    {
        FrindLinkModel model = new FrindLinkModel();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                hfId.Value = reqID.ToString();
                LoadData();
            }
        }

        private void LoadData()
        {
            
            model = CenterService.frindLinkService.GetOneById(reqID);
            if (model != null)
            {
                txtSiteName.Value = model.SiteName;
                txtSiteUrl.Value = model.SiteUrl;
                if (!string.IsNullOrEmpty(model.SitePic))
                {
                    spPic.Src = model.SitePic;
                }
                txtSiteOrderId.Value = model.SiteOrderId.ToString();
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            model = string.IsNullOrEmpty(hfId.Value) || hfId.Value == "0" ? new FrindLinkModel() : CenterService.frindLinkService.GetOneById(Convert.ToInt32(hfId.Value));
            model.SiteName = txtSiteName.Value;
            model.SiteUrl = txtSiteUrl.Value;
            model.SiteOrderId =Convert.ToInt32( txtSiteOrderId.Value);
            model.SiteID = CurrentSite.Id;
             
            if (hfId.Value != "0")
            {
                model.CreateUserId = AdminUser.Id;
            }////楼层ID
             

            if (CenterService.frindLinkService.Save(model) > 0)
            {

                JsHelper.CloseDialog(this, CommFunMsg.GetMessage("A0001", Lan.zh));
            }
            else
            {
                JsHelper.Alert(this, CommFunMsg.GetMessage("E0001", Lan.zh));
            }

        }
    }
}